<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head><title>BirthdayReminder | #{msg.registerTitle}</title>
<link href="css/mystyles.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" >
//simple javascript-function for resetting the value of a form field when the page is loaded
function initForm()
{
	var field = document.getElementById("myregform:confemail");
	field.setAttribute("value", "")
}
</script>
</h:head>
<h:body onload="initForm()">
<f:view locale="#{languageBean.activeLocale}">
<div align="center">
<h1>#{msg.registerHeadLine}</h1>
<fieldset>
<legend>#{msg.registerLegend}</legend>
<h:form id="myregform">
<h:messages styleClass="error" globalOnly="true"/>
<table>
  <tr><td>#{msg.registerUsername}</td><td><h:inputText id="username" required="true" requiredMessage="#{msg.registerUsernameError}"/></td>
  <td><h:message for="username" styleClass="error" /></td></tr> 
  
  <tr><td>#{msg.registerPassword}</td><td><h:inputSecret id="password" required="true" requiredMessage="#{msg.registerPasswordError}"/></td>
  <td><h:message for="password" styleClass="error"/></td></tr>
  
  <tr><td>#{msg.registerConfPassword}</td><td><h:inputSecret id="confpassword" required="true" requiredMessage="#{msg.registerConfPasswordError}"/></td>
  <td><h:message for="confpassword" styleClass="error" /></td></tr>
  
  <tr><td>#{msg.registerEmail}</td><td><h:inputText id="email" required="true" requiredMessage="#{msg.registerEmailError}" validatorMessage="#{msg.registerEmailPatternError}">
   <f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" /></h:inputText></td>
  <td><h:message for="email" styleClass="error" /></td></tr>
  
  <tr><td>#{msg.registerConfEmail}</td><td><h:inputText id="confemail" required="true" requiredMessage="#{msg.registerConfEmailError}" validatorMessage="#{msg.registerEmailPatternError}">
  <f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" /></h:inputText></td>
  <td><h:message for="confemail" styleClass="error" /></td></tr>
  <tr>
  <td>#{msg.registerNotificationType}</td>
  <td>
  <h:selectOneMenu id="ntype" required="true" requiredMessage="#{msg.registerNtypeError}" validatorMessage="#{msg.registerNtypeError}" >
  	<f:selectItem id="noselection" noSelectionOption="true" itemLabel="- - -" />
    <f:selectItems value="#{registrationBean.ntypelist}" var="type" itemValue="#{type.getId()}" itemLabel="#{type.getType()}"/>
  </h:selectOneMenu>
  </td>
  <td><h:message for="ntype" styleClass="error" /></td>
  </tr>
  <tr>
  <!-- Button löst doRegister aus. Diese Methode legt den neuen User an, sofern keine Fehler vorliegen -->
  <td><h:commandButton value="#{msg.registerButton}" action="#{registrationBean.doRegister}"/></td>
  <!-- Cancel-Button hat immediate=true damit die action vor jeglichen Validierungen ausgeführt wird -->
  <td><h:commandButton value="#{msg.registerCancel}" action="#{registrationBean.doCancel}" immediate="true"/></td>
  </tr>
  <tr>
  <td></td>
  </tr>
</table>
</h:form>
</fieldset>
</div>
</f:view>
</h:body>
</html>